package com.rul.mars.product.service.impl;

import com.github.pagehelper.PageHelper;
import com.rul.mars.mbg.mapper.ProductBrandMapper;
import com.rul.mars.mbg.model.ProductBrand;
import com.rul.mars.mbg.model.ProductBrandExample;
import com.rul.mars.product.service.ProductBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商品品牌服务实现
 *
 * @author RuL
 */
@Service
public class ProductBrandServiceImpl implements ProductBrandService {

    @Autowired
    private ProductBrandMapper productBrandMapper;

    /**
     * 查询商品品牌信息
     *
     * @param keywords 关键字
     * @param pageNum  页号
     * @param pageSize 页面大小
     * @return 商品品牌信息
     */
    @Override
    public List<ProductBrand> search(String keywords, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);

        ProductBrandExample example = new ProductBrandExample();
        example.createCriteria().andNameLike('%' + keywords + '%');

        return productBrandMapper.selectByExample(example);
    }
}
